package com.seele.tigerwallet.ui.views;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.seele.tigerwallet.R;

public class EmpteyView extends LinearLayout {
    private ImageView mImag;
    private TextView mTextView;

    public EmpteyView(Context context) {
        this(context, null);
    }

    public EmpteyView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public EmpteyView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        setLayoutParams(layoutParams);
        initView(context);
    }

    private void initView(Context context) {
        View view = View.inflate(context, R.layout.default_view, this);
        mImag = view.findViewById(R.id.default_img);
        mTextView = view.findViewById(R.id.default_tx);
    }


    public void setImg(int drawableId) {
        mImag.setImageDrawable(getResources().getDrawable(R.drawable.default_contact));
    }

    public void setText(int stringId) {
        mTextView.setText(getResources().getString(R.string.default_contact));
    }


    /**
     * 网络请求失败
     */
    public void setNetworkFailure() {
        mImag.setImageDrawable(getResources().getDrawable(R.drawable.default_wifi));
        mTextView.setText(getResources().getString(R.string.default_wifi));

    }


    /**
     * 网络加载失败
     */
    public void setDataFailed() {
        mImag.setImageDrawable(getResources().getDrawable(R.drawable.default_wifi));
        mTextView.setText(getResources().getString(R.string.default_data));
    }


    public static EmpteyView getDataFailedView(Context context) {
        EmpteyView empteyView = new EmpteyView(context);
        empteyView.setDataFailed();
        return empteyView;

    }


    public static EmpteyView getNetworkFailure(Context context) {
        EmpteyView empteyView = new EmpteyView(context);
        empteyView.setNetworkFailure();
        return empteyView;

    }


}
